import java.util.Scanner;

public class StudentManager {
    private DormitorySystem system;

    public StudentManager(DormitorySystem system) {
        this.system = system;
    }

    // 分配学生入住
    public void assignStudentToRoom() {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入房间号: ");
        String roomNumber = scanner.next();
        System.out.print("请输入床位号: ");
        int bedNumber = scanner.nextInt() - 1; // 床位编号从1开始，数组从0开始

        System.out.print("请输入学生姓名: ");
        String studentName = scanner.next();
        System.out.print("请输入学生学号: ");
        int studentId = scanner.nextInt();

        Room room = system.getRoomByNumber(roomNumber);
        if (room != null) {
            Student student = new Student(studentName, studentId);
            boolean success = room.assignStudentToBed(bedNumber, student);
            if (success) {
                System.out.println(studentName + " 成功入住房间 " + roomNumber);
            } else {
                System.out.println("分配失败，床位已被占用");
            }
        } else {
            System.out.println("房间未找到");
        }
    }
}
